* SM-E21-Table

use ../Metadata/tess_analysisdata.dta, clear

cd ../Results
putexcel set SM-E21-Table_NumhypSuccess.xlsx, replace

putexcel A1 = "Table E2.1. Average Rate of Positive Outcomes of Studies by Total Number of Hypotheses"


putexcel A2 = "No. of hypotheses"
putexcel B2 = "No. of studies"
putexcel C2 = "% hypotheses supported"
putexcel D2 = "% of positive result studies" 


putexcel A3= "1-5" 
putexcel A4= "6-10" 
putexcel A5= "11-20" 
putexcel A6= ">20" 
putexcel A7= "Total"


* create categorical indicator of number of hypotheses
	tab total_hyp
	recode total_hyp (1/5=1) (6/10=2) (11/20=3) (21/45=4), gen(totalhypcat)
	tab totalhypcat if hyp_num==1

cap frame change default	
capture frame drop table1
frame create table1 N mu1 mu2

* by # of hypotheses in study
forval i=1/4 {

	sum hyp_true if totalhypcat==`i' & insample==1
	scalar mu1 = `r(mean)'	

	sum successfulexp_insample if totalhypcat==`i' & hyp_num==1
	scalar mu2 = `r(mean)'

	scalar N1= `r(N)'
	



		frame post table1 (N1) (mu1) (mu2) 
	
}


* total row
	sum hyp_true if insample==1
	scalar mu1 = `r(mean)'	

	sum successfulexp_insample if hyp_num==1
	scalar mu2 = `r(mean)'

	scalar N1= `r(N)'	
	

		frame post table1 (N1) (mu1) (mu2) 
	
frame table1 {
	
	list

}
	
	
		
frame change table1

mkmat N mu1 mu2, mat(mymatrix)
mat list mymatrix



putexcel B3= matrix(mymatrix), nformat(number_d2)
putexcel B3:B8, overwritefmt nformat(##0)


putexcel (A1:D1), bold border(bottom)
putexcel (A2:D2), border(bottom)
putexcel (A6:D7), border(bottom)

putexcel A8= "Note: Positive study result is defined as having at least one supported hypothesis for studies with up to 10 hypotheses or at least 10% supported hypotheses for studies with >10 hypotheses. Analysis sample excludes non-treatment and no-difference hypotheses."

putexcel (A1:F9), font(timesnewroman, 11)
frame change default

cd ../Script
